package com.qianduo.service.impl;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import com.qianduo.dao.IQianduoOrderDao;
import com.qianduo.po.QianduoOrder;
import com.qianduo.po.QianduoOrderView;
import com.qianduo.util.Constants;
import com.qianduo.util.ServiceUtil;
import com.qianduo.vo.QianduoOrderForm;

import common.page.PageList;
import common.util.ObjectUtil;
@SuppressWarnings("finally")
public class QianduoOrderServiceImpl extends ServiceUtil{
	private IQianduoOrderDao qianduoOrderDao;	
	
	
	public IQianduoOrderDao getQianduoOrderDao() {
		return qianduoOrderDao;
	}

	public void setQianduoOrderDao(IQianduoOrderDao qianduoOrderDao) {
		this.qianduoOrderDao = qianduoOrderDao;
	}
	
	public boolean saveOrUpdateOrder(QianduoOrderForm vo){
		boolean ret		= false;
		try{
			QianduoOrder po	= new QianduoOrder();
			ObjectUtil.copyProperties(po, vo);
			qianduoOrderDao.saveOrUpdateOrder(po);
			
			ret		= true;
		}catch(Exception e){
			Constants.log.error(className+" saveOrUpdateOrder",e);
		}finally{
			return ret;
		}
	}
	
	public List<QianduoOrderForm> listOrder(Integer id,Integer agencyID,String name,BigDecimal minAmount,BigDecimal maxAmount,Integer cityID,String mobile,Integer isMortgage,String mortgageType,Integer minAge,Integer maxAge,Integer wage,String createDateStart,String createDateEnd,PageList pageList) {
		List<QianduoOrderForm> retList	= null;
		try{
			List<QianduoOrderView> listPO	= qianduoOrderDao.listOrder(id, agencyID, name, minAmount, maxAmount, cityID, mobile, isMortgage, mortgageType, minAge, maxAge, wage, createDateStart, createDateEnd, pageList);
			if(null != listPO && listPO.size() > 0){
				retList	= new ArrayList<QianduoOrderForm>();
				for(QianduoOrderView po : listPO){
					QianduoOrderForm vo	= new QianduoOrderForm();
					ObjectUtil.copyProperties(vo, po);
					
					retList.add(vo);
				}
			}
		}catch(Exception e){
			Constants.log.error(className+" listOrder",e);
		}finally{
			return retList;
		}
	}
}
